package com.stars.empoly.jupsh.componnent

import android.content.Context
import android.graphics.Color
import android.net.ConnectivityManager
import android.text.SpannableString
import android.text.Spanned
import android.text.style.AbsoluteSizeSpan
import android.text.style.ForegroundColorSpan
import android.util.Log
import android.widget.*
import cn.jpush.android.api.JPushInterface
import com.stars.empoly.BuildConfig
import com.stars.empoly.R
import com.stars.empoly.jupsh.utils.Alias


/**
 *
 *on 2020/9/9
 */
object JpushUtils {



    fun initPush(context: Context?) {//初始化极光推送
        JPushInterface.setDebugMode(BuildConfig.DEBUG) //打印log
        JPushInterface.init(context)
    }

    fun setPushAlias(context: Context?, uid: String) {//别名推送
//        极光推送针对的是设备
//        设置的别名是跟设备的registrationID绑定

//        val rid = JPushInterface.getRegistrationID(context)
//        Log.e("-shy-", "rid=: "+rid )
//        if (rid.isEmpty()) {
        Alias.alias = "US_$uid"
        Alias.tag = uid.toInt()
        JPushInterface.resumePush(context)
        JPushInterface.setAlias(context, uid.toInt(), "US_$uid")
//        }

    }

    fun setClearAlias(context: Context?, uid: String) {//清空别名

        JPushInterface.deleteAlias(context, uid.toInt())
        JPushInterface.stopPush(context)


    }


}
